class Solution:
    def maxOperations(self, s: str) -> int:

        ans, o = 0, 0
        for i, c in enumerate(s):
            if c == "1":
                o += 1
            elif i == 0 or s[i - 1] != "0":
                ans += o

        return ans
